layui.use(['form','layer','laydate','table','util'],function (){
    let form = layui.form,layer = layui.layer,laydate = layui.laydate,table = layui.table,util = layui.util;
    let dateElem = $('.form-dateElem');
    //渲染日期模块，最大日期为当前日期
    layui.each(dateElem,function () {
        laydate.render({
            elem:this,
            //最大日期比今天多几天
            max:0,
        })
    })
})

/**
 * @author: ChengJW
 * @params:
 * @return:
 * @date: 2021/9/22
 * @description: 初始化生成table数据
 */
$(function () {
    queryStatisticsDataList();
})

/**
 * @author: ChengJW
 * @params:
 * @return:
 * @date: 2021/9/22
 * @description: 生成table数据
 */
function queryStatisticsDataList() {
    //起始日期
    let stDt = $('#stDt').val();
    //截止日期
    let lmDt = $('#lmDt').val();
    //管辖机关
    let srchReqFir = $("select[name = 'srchReqFir']").val();

    let stDtClean = valueClean(stDt,"-");
    let lmDtClean = valueClean(lmDt,"-");
    if (!valueIsEmpty(stDt) && ! valueIsEmpty(lmDt) && stDtClean > lmDtClean){
        top.layer.alert("起始日期不能大于截止日期");
        return;
    }
    let jsonData = {
        "srchReqFir" : srchReqFir,
        "qryReqFir" : "shouLi",
        "stDt" : stDt,
        "lmDt" : lmDt
    }
    //时间戳
    let tableTitle = '受理信息统计表'+layui.util.toDateString(new Date(),'yyyyMMddHHmmss');
    layui.table.render({
        elem:'#dataTable',
        id:'dataTableId',
        url:'/statistics/statisticsCom/queryStatisticsDataList',
        parseData:function (result) {
            return{
                "code":result.code,
                "msg":result.msg,
                "count":result.data.pageCount,
                "data":result.data.list
            }
        },
        size:'sm',
        //分页的起止页号，每页条数
        page:{
            curr:1,
            limit:10,
            limits:[10,30]
        },
        //自定义的页码参数名称、每页条数参数名称
        request:{
            pageName:'pageNum',
            limitName:'pageSize'
        },
        //table的高度
        height:480,
        //查询条件，json格式
        where:jsonData,
        cols:[[
            {type:'numbers',title:'序号'},
            {field:'mgeNm',title:'管辖单位',align:'center',totalRowText:'合计'},
            {field:'acptNum1',title:'档案登记',align:'center',totalRow:true,templet:function (d) {
                    return d.acptNum1 + ' 卷';
                }},
            {field:'acptNum2',title:'档案数字化',align:'center',totalRow:true,templet:function (d) {
                    return d.acptNum2 + ' 卷';
                }},
            {field:'acptNum3',title:'数字化完成',align:'center',totalRow:true,templet:function (d) {
                    return d.acptNum3 + ' 卷';
                }},
            {field:'acptNum4',title:'档案入库',align:'center',totalRow:true,templet:function (d) {
                    return d.acptNum4 + ' 卷';
                }},
            {field:'acptNum5',title:'档案出库',align:'center',totalRow:true,templet:function (d) {
                    return d.acptNum5 + ' 卷';
                }},
            {field:'acptTotalNum',title:'总计',align:'center',totalRow:true,templet:function (d) {
                    return d.acptTotalNum + ' 卷';
                }},
            {field:'sticsDate',title:'统计日期',align:'center'}
        ]],
        //头部工具条
        toolbar: true,
        //开启合计
        totalRow:true,
        //导出时候excel文件标题
        title:tableTitle
    });
}

/**
 * @author: ChengJW
 * @params:
 * @return:
 * @date: 2021/12/2
 * @description: 获取选中行的业务申请编号集合
 */
function getAtBussIdList(aceptData) {
    let atBussIdList = "";
    for (let i=0;i < aceptData.length; i++){
        if (valueIsEqual(atBussIdList,"")){
            atBussIdList = aceptData[i].atBussId ;
        }else {
            atBussIdList = atBussIdList + "," + aceptData[i].atBussId;
        }
    }
    return atBussIdList;
}